package com.study.controller;

import com.study.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.LinkedHashMap;

/**
 * UserController class
 *
 * @author chenyeqing
 * @date 2021/3/22
 */
@Controller
@RequestMapping("/u1")
public class UserController {

    @GetMapping("/t1")
    public String test1(@RequestParam("username") String name, Model model) {
        // 1. 接收前端参数
        System.out.println("接收到的前端参数为：" + name);

        // 2. 将返回的结果传递给前端
        model.addAttribute("msg", name);
        return "test";
    }

    @GetMapping("/t2")
    public String test2(User user) {
        System.out.println(user);
        return "test";
    }

    @GetMapping("/t3")
    public String test03(LinkedHashMap map) {
        map.put("msg", "reqreqrqwreqwwe");
        return "test";
    }

}
